package com.tianhaochen.springai.config;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration
public class ChatClientConfig {
    private final RedisChatMemory redisChatMemory;
    private final MongoChatMemory mongoChatMemory;

    @Bean
    public ChatClient chatClient(OllamaChatModel model) {
        return ChatClient.builder(model)
                .defaultAdvisors(new MessageChatMemoryAdvisor(mongoChatMemory))
                .build();
    }
}
